package com.github.lanif.modular.project.controller;

import com.github.lanif.core.pojo.response.ResponseData;
import com.github.lanif.core.pojo.response.SuccessResponseData;
import com.github.lanif.modular.project.param.ProjectParam;
import com.github.lanif.modular.project.service.ProjectService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 项目
 *
 * @author WEI.Q.
 * @description
 */
@RestController
@RequestMapping("/project")
public class ProjectController {
    @Resource
    private ProjectService projectService;

    @GetMapping("page")
    public ResponseData page(ProjectParam projectParam) {
        return new SuccessResponseData(projectService.page(projectParam));
    }

    @PostMapping("delete")
    public ResponseData delete(@RequestBody @Validated(ProjectParam.delete.class) ProjectParam projectParam) {
        projectService.delete(projectParam);
        return new SuccessResponseData();
    }

    @PostMapping("add")
    public ResponseData add(@RequestBody @Validated(ProjectParam.add.class) ProjectParam projectParam) {
        projectService.add(projectParam);
        return new SuccessResponseData();
    }

    @PostMapping("edit")
    public ResponseData edit(@RequestBody @Validated(ProjectParam.edit.class) ProjectParam projectParam) {
        projectService.edit(projectParam);
        return new SuccessResponseData();
    }
}
